//
//  UIImageView+GIF.swift
//  GifUsage
//
//  Created by Ting Han on 2020/12/19.
//  Copyright © 2020 Ting Han. All rights reserved.
//

import UIKit

var kGIFAnimatorKey = "GIFAnimatorKey"
extension UIImageView: GIFAnimatable {
    var animator: GIFAnimator? {
        get {
          guard let animator = objc_getAssociatedObject(self, &kGIFAnimatorKey) as? GIFAnimator else {
            let animator = GIFAnimator(withDelegate: self)
            self.animator = animator
            return animator
          }
          return animator
        }

        set {
          objc_setAssociatedObject(self, &kGIFAnimatorKey, newValue as GIFAnimator?, .OBJC_ASSOCIATION_RETAIN_NONATOMIC)
        }
    }

}

extension UIImageView: ImageContainer {}

